<?php 
$params  = array('foo' => 'bar');

$temp = $this->page_link;
$temp['style'] = 'grid';
$styleOpts = array(
	'query' => $temp
);

if ($this->page_link['page'] != $this->number_of_pages)
{
	$temp = $this->page_link;
	$temp['page'] += 1;
	$nextOpts = array(
		'query' => $temp
	);
}
if ($this->page_link['page'] != 1)
{
	$temp = $this->page_link;
	$temp['page'] -= 1;
	$prevOpts = array(
			'query' => $temp
	);
}

$this->headTitle('Trang danh mục');
?>

<div class="newTitleDiv clearfix">
	<h2 class="newTitleNoBg"><?php echo $this->department['name'];?></h2>
	<div class="newTitleShadow"></div>
	<div class="newTitleBg"></div>
</div>
<div class="titleDiv">
	<h2><?php echo $this->department['category']['name']?></h2>
	<div class="holder">
		<p><a href="<?php echo $this->Url('catalog', $params, $styleOpts);?>" class="view1_2"></a><a class="view2_2"></a></p>
		<div class="sort-holder">
			<span>Sort By</span>
			<ul>
				<li><a href="#">Name</a></li>
				<li><a href="#">Price</a></li>
				<li><a href="#">Brand</a></li>
				<li><a href="#">Relevance</a></li>
			</ul>
		</div>
	</div>
</div>
<div class="contentBox contentBox2 contentBox3">
<?php
if($this->department['category']['products']){
foreach($this->department['category']['products'] as $item)
{
	$text = <<<_END
	<div class="catalogBox clearfix">
		<div class="catalogBoxLeft clearfix">
			<div class="catalogThumbs">
				<div><a href="%s"><img src="%s" alt="" width="33" height="51" /></a></div>
				<div><a href="%s"><img src="%s" alt="" width="33" height="51" /></a></div>
				<div class="catalogThumbLast"><a href="%s"><img src="%s" alt="" width="33" height="51" /></a></div>
			</div>
			<div class="catalogImage">
				<img src="%s" alt="" />
			</div>
		</div>
		<div class="catalogBoxRight">
			<div class="catalogBoxRightTop clearfix">
				<div class="catalogProductTitle">
					<h2>%s</h2>
				</div>	
				<div class="catalogProductAddTo">
					<a href="wishlist.html">Thêm vào yêu thích</a> |
					<a href="compare.html">Thêm vào so sánh</a>
					<span>%s</span>
				</div>
			</div>
			<div class="catalogBoxRightBottom clearfix">
				<div class="catalogProductInfo clearfix">
					<div class="catalogProductInfoLeft">
						<p>%u<sup>.000</sup><sub>vnd</sub></p>
					</div>
					<div class="catalogProductInfoCenter">
						<p><span>Tình trạng:</span>%s</p>
						<p><span>Mã sản phẩm:</span>%s</p>
					</div>
					<div class="catalogProductInfoRight">
						<p><span>Hãng sản xuất:</span>%s</p>
						<p><span>Bảo hành:</span>%u tháng</p>
					</div>
				</div>
				<div class="catalogProductButtons">
					<a href="%s" class="productsMoreBtn">Chi tiết</a>
					<a href="%s" class="productsMoreBtn">Đặt hàng</a>
				</div>
			</div>
		</div>
	</div>
_END;
	$image_url_1 = $this->basePath() . '/images/' . $item['thumbnail']['image_1'];
	$image_url_2 = $this->basePath() . '/images/' . $item['thumbnail']['image_2'];
	$image_url_3 = $this->basePath() . '/images/' . $item['thumbnail']['image_3'];
	$star = '';
	for($i = 1; $i<=$item['star']; $i++)
	{
		$star .= '<a href="#" class="star1"></a>';
	}
	for($i = 1; $i<= 5 - $item['star']; $i++)
	{
		$star .= '<a href="#" class="star2"></a>';
	}
	if($item['in_stock'])
		$in_stock = 'Còn hàng';
	else
		$in_stock = 'Hết hàng';
	echo sprintf($text, $image_url_1, $image_url_1, $image_url_2, $image_url_2, $image_url_3, $image_url_3, $image_url_1,
			$item['name'], $star, $item['price'], $in_stock , $item['product_code'], $item['brand'], $item['warranty'],
			'pro', 'cart'
	);
}}
?>
	<div class="latestProductsNav">
	<?php 
	if($this->number_of_pages > 1)
	{
		echo '<ul class="clearfix">';
		echo '<li class="prev">'; if($this->page_link['page'] != 1) echo '<a href="' . $this->Url('catalog', $params, $prevOpts) . '">&lt;</a></li>';
			for ($i=1; $i <= $this->number_of_pages; $i++)
			{
			  	if($i == $this->page_link['page'])
			  		echo '<li><a class="activeLPN">'.$i.'</a></li>';
			  	else
			  	{
			  		$temp = $this->page_link;
			  		$temp['page'] = $i;
			  		$toPageOpts = array(
			  			'query' => $temp
			  		);
					echo '<li><a href="'. $this->Url('catalog', $params, $toPageOpts) .'">'.$i.'</a></li>';
			  	}			  				
			}
		echo '<li class="next">'; if($this->page_link['page'] != $this->number_of_pages) echo '<a href="' . $this->Url('catalog', $params, $nextOpts) . '">&gt;</a></li>';
		echo '</ul>';
	}
	?>
	</div>
</div>


				<div class="titleDiv titleDiv2">
				<h2>Related Products</h2>
			</div>
			<div class="relatedProducts">
				<ul>
					<li class="relProduct">
						<div class="relProductImage">
							<a href="product.html"><img src="images/related-product-image1.png" alt="" /></a>
						</div>
						<div class="relProductInfo">
							<p><a href="product.html">vizio m221 nv</a></p>
							<div>259<sup>.99</sup><sub>usd</sub></div>
						</div>
					</li>
					<li class="relProduct">
						<div class="relProductImage">
							<a href="product.html"><img src="images/related-product-image2.png" alt="" /></a>
						</div>
						<div class="relProductInfo">
							<p><a href="product.html">sennheiser pxc</a></p>
							<div>1199<sup>.99</sup><sub>usd</sub></div>
						</div>
					</li>
					<li class="relProduct">
						<div class="relProductImage">
							<a href="product.html"><img src="images/related-product-image3.png" alt="" /></a>
						</div>
						<div class="relProductInfo">
							<p><a href="product.html">ipad2</a></p>
							<div>559<sup>.99</sup><sub>usd</sub></div>
						</div>
					</li>
					<li class="relProduct">
						<div class="relProductImage">
							<a href="product.html"><img src="images/related-product-image4.png" alt="" /></a>
						</div>
						<div class="relProductInfo">
							<p><a href="product.html">macbook air</a></p>
							<div>1259<sup>.99</sup><sub>usd</sub></div>
						</div>
					</li>
				</ul>
			</div>